import http from "@/utils/Http.ts";

export interface TimeTask {
    id:number,
    taskId:string,
    taskName:string,
    taskGroup:string,
    taskStatus:number,
    taskType:string,
    cronExpr:string,
    subType:string,
    taskData:string,
    taskExtendParam:string,
    updateTime:string,
    createTime:string
}

export const getTimeTastList = () => {
    return http<Array<TimeTask>>({
        url: '/task/taskList',
        method: 'get'
    })
}

export const updateTaskStatus = (taskId:string, taskStatus:number) => {
    return http({
        url: '/task/updateTaskStatus',
        method: 'post',
        data: {"taskId": taskId, "taskStatus": taskStatus}
    })
}

export interface addTaskData {
    taskName:string,
    taskGroup:string,
    taskStatus:number,
    taskType:string,
    cronExpr:string,
    subType:string,
    taskData:string,
    taskExtendParam:string
}

export const addTask = (data: addTaskData) => {
    return http({
        url: '/task/addTask',
        method: 'post',
        data: data
    })
}

export const deleteTask = (taskId: string) => {
    return http({
        url: '/task/deleteTask',
        method: 'post',
        data: {"taskId": taskId}
    })
}

export const execTaskTest = (data: addTaskData) => {
    return http({
        url: '/task/execTaskTest',
        method: 'post',
        data: data
    })
}